<?php
namespace app\admin\model;

use think\Model;

class BaseModel extends Model
{
	/**
     * 分页获取数据
     *
     * @param array $where
     * @param int $nowPage
     * @param int $limit
     * @param array $order
     * @param array $field
     * @return array|array[]|\array[][]
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getPageData($where = [], $nowPage=1, $limit = 10, $order = ['id', 'desc'], $field = [], $date = null)
    {
        $data = self::where($where);
        // 字段限制
        if (!empty($field)) {
            $data = $data->field($field);
        }
        // 根据时间查找
        if ($date) {
            $data = $data->whereTime('Order_time', 'between', $date);
        }

        // 排序
        $data = $data->order($order[0], $order[1]);
        $data = $data->page($nowPage, $limit)->select();
        return $data;
    }
}
